package com.aspose.cells;

import java.util.ArrayList;
import java.util.Iterator;

class ztv {
   private Workbook a;
   private zok b;
   private zty c;

   ztv(zok var1, zty var2) {
      this.a = var1.a;
      this.b = var1;
      this.c = var2;
   }

   void a(zcfx var1) throws Exception {
      var1.b(true);
      var1.b("sst");
      if (zase.a) {
         var1.a("xmlns", zase.c);
      } else {
         var1.a("xmlns", zase.d);
      }

      zbpx var2 = this.a.getWorksheets().g;
      zalh var3 = this.b.u;
      var1.a("count", zase.a(var3 == null ? var2.c() & 4294967295L : var3.i & 4294967295L));
      var1.a("uniqueCount", zase.y(var3 == null ? var2.d() : var3.d + var3.g.size()));
      int var4;
      if (var3 == null) {
         var4 = var2.d();
      } else {
         var4 = var3.d;
      }

      for(int var5 = 0; var5 < var4; ++var5) {
         zayy var6 = var2.a[var5];
         var1.b("si");
         if (var6 == null) {
            a(var1, "r");
         } else {
            if (var6.f()) {
               a(var1, (zbap)var6, this.a);
            } else {
               a(var1, var6);
            }

            if (var6.g()) {
               zatu var7 = ((zatv)var6).a();
               if (var7 != null && var7.c.getCount() > 0) {
                  a(var1, var7, this.c);
               }
            }
         }

         var1.b();
      }

      if (var3 != null) {
         Iterator var8 = var3.g.iterator();

         while(var8.hasNext()) {
            String var9 = (String)var8.next();
            var1.b("si");
            a(var1, var9);
            var1.b();
         }
      }

      var1.b();
      var1.d();
      var1.e();
   }

   static void a(zcfx var0, zatu var1, zty var2) throws Exception {
      int var3;
      for(var3 = 0; var3 < var1.c.getCount(); ++var3) {
         zats var4 = var1.c.a(var3);
         var0.b("rPh");
         var0.a("sb", (String)null, zase.y(var4.a));
         var0.a("eb", (String)null, zase.y(var4.a + var4.b - 1));
         a(var0, var4.c);
         var0.b();
      }

      var0.b("phoneticPr");
      if (var2.a.b.containsKey(var1.b)) {
         var3 = (Integer)var2.a.b.get(var1.b);
         var0.a("fontId", (String)null, zase.y(var3));
      }

      String var5;
      if (var1.a() != 2) {
         var5 = "left";
         switch(var1.a()) {
         case 0:
            var5 = "center";
            break;
         case 1:
            var5 = "Distributed";
         case 2:
         default:
            break;
         case 3:
            var5 = "noControl";
         }

         var0.a("alignment", (String)null, var5);
      }

      if (var1.b() != 0) {
         var5 = "fullwidthKatakana";
         switch(var1.b()) {
         case 1:
            var5 = "halfwidthKatakana";
            break;
         case 2:
            var5 = "Hiragana";
            break;
         case 3:
            var5 = "noConversion";
         }

         var0.a("type", (String)null, var5);
      }

      var0.b();
   }

   static void a(zcfx var0, zayy var1) throws Exception {
      String var2 = var1.c;
      if (var2.length() > 32767) {
         var2 = var2.substring(0, 32767);
      }

      a(var0, var2);
   }

   static void a(zcfx var0, String var1) throws Exception {
      var0.b("t");
      if (var1 != null && !"".equals(var1)) {
         if (zase.al(var1)) {
            var0.a("xml:space", (String)null, "preserve");
         }

         var0.a(var1);
      }

      var0.b();
   }

   static void a(zcfx var0, zbap var1, Workbook var2) throws Exception {
      if (var1.h().length == 0) {
         a(var0, var1.c);
      } else {
         ArrayList var3 = zot.a(var1, (Font)null, var2);

         for(int var4 = 0; var4 < var3.size(); ++var4) {
            zot var5 = (zot)var3.get(var4);
            var0.b("r");
            if (var5.b != null) {
               var0.b("rPr");
               zty.a(var5.b, var0, "rFont");
               var0.b();
            }

            a(var0, var5.a);
            var0.b();
         }
      }

   }
}
